package com.crm.service.crm.clue.controller;

import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.crm.clue.dtos.ClueDto;
import com.crm.model.crm.clue.dtos.ClueSearchDto;
import com.crm.model.crm.clue.vos.CueingResultVO;
import com.crm.service.crm.clue.service.ClueSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/clue")
public class ClueSController {

    @Autowired
    private ClueSService clueService;

    /**
     * 分页查询与条件查询
     * @param dto
     * @return
     */
    @PostMapping("/search")
    public ResponseResult search(@RequestBody ClueSearchDto dto){
        return clueService.search(dto);
    }

    /**
     * 导出模板
     * @param response
     * @return
     */
    @GetMapping("/template")
    public ResponseResult template(HttpServletResponse response){
        return clueService.template(response);
    }

    /**
     * 上传表格
     * @param culeTable
     * @return
     */
    @PostMapping("/import")
    public ResponseResult importTableClue(@RequestParam("culeTable")MultipartFile culeTable){
        return clueService.importClueTabel(culeTable);
    }

    /**
     * 删除上传表格
     * @return
     */
    @DeleteMapping("/upload_delete")
    public ResponseResult uploadClueDelete(){
        return clueService.uploadClueDelete();
    }

    /**
     * 效验批量上传线索结果
     * @return
     */
    @GetMapping("/verification_result")
    public ResponseResult verificationClueResult(){
        return clueService.verificationClueResult();
    }

    /**
     * 保存批量上传的线索
     * @return
     */
    @PostMapping("/batch-save")
    public ResponseResult clueBatchSave(){
        return clueService.clueBatchSave();
    }

    /**
     * 校验结果下载
     * @param dto
     * @param response
     * @return
     */
    @PostMapping("/check-result-download")
    public ResponseResult checkResultDownload(@RequestBody CueingResultVO dto,HttpServletResponse response ){
        return clueService.checkResultDownload(dto,response);
    }

    /**
     * 新建线索
     * @param dto
     * @return
     */
    @PostMapping("/newClue")
    public ResponseResult newClue(@RequestBody ClueDto dto){
        return clueService.saveNewClue(dto);
    }

    /**
     * 回显部门
     * @return
     */
    @GetMapping("/department")
    public ResponseResult findAllDepartment(){
        return clueService.findAllDepartment();
    }

}
